﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace NGO_Application
{
    public partial class Manage_State : Form
    {
        public Manage_State()
        {
            InitializeComponent();
        }

        readonly string _strConnectionString = ConfigurationManager.AppSettings["AccessDBConnectionString"];
        private string _accessInsertQuery = string.Empty;


        /// <summary>
        /// State Submit Button Click Functionality
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        #region State Submit Button Click 
        private void btnStateSubmit_Click(object sender, EventArgs e)
        {
            
            OleDbConnection connection = new OleDbConnection(_strConnectionString);
            OleDbCommand _command = new OleDbCommand();
            connection.Open();
            
            string strStateName = UtilityClass.ReplaceSingleQuote(txtStateName.Text);
            string strStateCode = UtilityClass.ReplaceSingleQuote(txtStateCode.Text);
            bool stateIsActive = chkStateActive.Checked;

            try
            {

                _accessInsertQuery = "INSERT INTO State_Details(State_Name,State_Code,IsActive) Values ('" + strStateName + "', '" + strStateCode +
                                     "', '" + stateIsActive + "')";
                _command.CommandText = _accessInsertQuery;
                _command.Connection = connection;
                _command.ExecuteNonQuery();
                
            }
            catch (Exception ex)
            {
                lblMessage.Visible = true;
                lblMessage.Text = ex.Message;
            }

        }
        #endregion 
    }
}
